function delete_all(route, needConfirm) {
    if (needConfirm) {
        if (confirm("是否删除所选项")) {
            do_delete_all(route);
        }
    } else {
        do_delete_all(route);
    }
}

function do_delete_all(route) {
    var keys = $(".grid-view").yiiGridView("getSelectedRows");
    console.log(keys);
    $.post(route, {ids: keys}, function(result){
        console.log("result:" + result);
        var result = JSON.parse(result);
        if (result.status == 1) {
            alert(result.content);
            window.location.reload();
        } else {
            alert(result.content);
        }
    });
}

function update_all_multi(route, ops, needConfirm) {
    // var ops =
    // [
    //     {
    //         field: field,
    //         value: value
    //     }
    // ];
    if (needConfirm) {
        if (confirm("是否更新所选项")) {
            do_update_all(route, ops);
        }
    } else {
        do_update_all(route, ops);
    }
}

function update_all(route, field, value, needConfirm) {
    var ops =
    [
        {
            field: field,
            value: value
        }
    ];
    if (needConfirm) {
        if (confirm("是否更新所选项")) {
            do_update_all(route, ops);
        }
    } else {
        do_update_all(route, ops);
    }
}

function do_update_all(route, ops) {
    console.log("_do_update_all:"+ops)
    var keys = $(".grid-view").yiiGridView("getSelectedRows");
    console.log(keys);

    $.post(route, {ids: keys, ops: ops},function(result){
        console.log("result:" + result);
        var result = JSON.parse(result);
        if (result.status == 1) {
            alert(result.content);
            window.location.reload();
        } else {
            alert(result.content);
        }
    });
}